# P377-P383
# 小明爱跑步
# 需求
# 1、小明体重75kg    2、小明每次跑步会减肥0.5kg    3、小明每次吃东西体重增加1kg
# class Person:
#     name = ""
#     weight = 0
#     symbol = "kg"
#
#     def __init__(self, name, weight):
#         self.name = name
#         self.weight = weight
#
#     def run(self):
#         self.weight -= 0.5
#
#     def eat(self):
#         self.weight += 1
#
#     def now_weight(self):
#         print("%s现在的体重是%.02f%s" % (self.name, self.weight, self.symbol))
#
# xiaoming_object = Person("小明", 75)
# xiaoming_object.run()
# xiaoming_object.run()
# xiaoming_object.run()
# xiaoming_object.run()
# xiaoming_object.run()
# xiaoming_object.eat()
# xiaoming_object.eat()
# xiaoming_object.eat()
# xiaoming_object.now_weight()

# 需求
# 1、房子House有弧形、总面积和家居名称列表
# 2、家居HouseItem有名字和占地面积 （1）席梦思占地4平方米    （2）衣柜占地2平方米 （3）餐桌占地1.5平方米
# 3、将以上三件家具添加到房子中
# 4、打印房子时，要求输出：户型、总面积、剩余面积、家具名称列表
class House:
    # 定义特征属性
    house_type = ""
    total_area = 0
    furniture = []
    def __init__(self, house_type, total_area, furniture):
        self.house_type = house_type
        self.total_area = total_area
        self.furniture = furniture

    def get_house_info(self):
        """获取房子基础信息

        """
        # 遍历列表计算房子的剩余大小
        surplus = self.total_area
        furniture_name_list = ""
        for furniture_name in self.furniture:
            for key in furniture_name:
                furniture_name_list += str(key) + "   "
                surplus -= float(furniture_name[key])
        print("房子的户型是%s，总面积%.02f，剩余面积%.02f，家具列表%s" % (self.house_type, self.total_area, surplus, furniture_name_list))

class HouseItem:
    furniture_list = []

    def add_furniture(self, furniture_name, furniture_area):
        new_furniture = {furniture_name: furniture_area}
        self.furniture_list.append(new_furniture)

# 我先准备一下房子的家具
house_furniture_object = HouseItem()
# 添加家具进去
house_furniture_object.add_furniture("bed", 4)
house_furniture_object.add_furniture("bed", 4)
house_furniture_object.add_furniture("chest", 2)
house_furniture_object.add_furniture("table", 1.5)
# 先买房子
house_object = House("别墅", 300, house_furniture_object.furniture_list)
house_object.get_house_info()
